#ifndef IMPSURFACE_H
#define IMPSURFACE_H

#include "geometry.h"

class ImpSurface;
class IsoSurface;

const Double GRAD_EPSILON = 1e-5;
const Double GRAD_EPS_INV = 1.0 / GRAD_EPSILON;

class ImpSurface
{
public:
	ImpSurface			();
	virtual	~ImpSurface	();

	virtual Double	eval	(Double x, Double y, Double z) 
								{ return eval(Point3d(x, y, z)); }
	virtual Double	eval	(Double x, Double y, Double z, Double t) 
								{ return eval(Point3d(x, y, z), t); }
	virtual Double	eval	(const Point3d& location) = 0;
	virtual Double	eval	(const Point3d& location, Double t);

	Vector3d		grad	(const Point3d& location);
	Vector3d		normal	(const Point3d& location);
private:
	
};

class IsoSurface
{
public:
	IsoSurface			();
	IsoSurface			(ImpSurface* function_);
	~IsoSurface			();
	
	int	addVertex	(Point3d toAdd); // carlos eduardo int addVertex	(Point3d& toAdd);
	void	addFace		(int v1, int v2, int v3);
	void	addFace		(MeshTriangle& toAdd);

	void	glDraw		();

	void	calcVNorms	();

	void	clear		();

	ImpSurface*	getFunction	();

	friend ostream& operator <<		(ostream& out, const IsoSurface& s);
private:
	ImpSurface*				function;
	vector<Point3d>			vertices;
	vector<MeshTriangle>	faces;
	vector<Vector3d>		vNormals;
};

#endif // IMPSURFACE_H

